Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

locate-path

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

locate-path

Get the first path that exists on disk of multiple paths

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is locate-path?

The locate-path npm package is designed to find a file or directory by looking for it in multiple paths. It is useful for situations where you need to locate a file but are unsure of its exact location within a list of possible directories. It can be used synchronously or asynchronously and supports both promises and async/await syntax.

What are locate-path's main functionalities?

Asynchronous Path Location

This feature allows you to asynchronously locate a file or directory from an array of paths. The first path that contains the file or directory is returned.

const locatePath = require('locate-path');

(async () => {
  const foundPath = await locatePath(['unicorn.png', 'rainbow.png'], {cwd: 'images'});
  console.log(foundPath);
  //=> 'images/unicorn.png'
})();

Synchronous Path Location

This feature provides a synchronous way to locate a file or directory from an array of paths. It is useful when you need to find a path in a blocking manner.

const locatePath = require('locate-path');

const foundPath = locatePath.sync(['unicorn.png', 'rainbow.png'], {cwd: 'images'});
console.log(foundPath);
//=> 'images/unicorn.png'

Other packages similar to locate-path

Keywords

FAQs

Package last updated on 17 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc